package com.study.parse;

import io.milvus.grpc.FieldData;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;
import java.util.List;
@Component
public class FloatArrayParseResolver extends AbstractParseResolver {

    @Override
    public boolean isSupport(Field field) {
        return field.getType().getTypeName().equals("float[]");
    }

    @Override
    public <T> void resolveParamBind(T ins, Field field, FieldData fieldData, int index) throws IllegalAccessException {
        List<Float> dataList = fieldData.getVectors().getFloatVector().getDataList();
        float[] floatArray = new float[dataList.size()];
        for (int j = 0; j < dataList.size(); j++) {
            floatArray[j] = dataList.get(j);
        }
        field.set(ins, floatArray);
    }
}
